Here's a small example. For this example to run, the php file needs certain variables to be set like the host, database, etc.

First it creates a new recordset, then it sets the data bridge file for thisrecordset.

If this line is omitted it uses xmlquery.php by default.

Then the actual query is send to the database.

When the results have been interpreted correctly the onQueried event function will be executed. In this example it fills a listbox with information retrieved from the database.

myData = new KRecordSet();
myData.setDataBridge('xmlquery.php');
myData.query("select * from koolmoves order by name");
myData.onQueried = function(){
  for (var i = 0 ; i < this.records.length ; i++ ) {
    listbox1.addItem( this.records[i].name , this.records[i] );
  }
}

By default only select queries are allowed. A little extra information about it is in the xmlquery.php file attached. It should be possible to use insert queries to add data but since there's no way to protect the actionscript code of a swf file anyone who would study the swf could add unwanted information to the database. Because of this unability to protect the actionscript code from being viewed by an actionscript viewer it's also wise not to use a database that contains classified information.

This is the table used in this example:

CREATE TABLE koolmoves (
  id int(10) unsigned NOT NULL auto_increment,
  name tinytext NOT NULL,
  kmversion tinytext NOT NULL,
  filesize tinytext NOT NULL,
  description mediumtext NOT NULL,
  urldemo tinytext NOT NULL,
  urldownload tinytext NOT NULL,
  PRIMARY KEY  (id)
) TYPE=MyISAM;



